package com.zr.controller;

import java.io.IOException;





import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zr.model.Customer;
import com.zr.service.CkgrxxService;
import com.zr.serviceimp.CkgrxxServiceImpl;


import java.io.IOException;





import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zr.model.Customer;
import com.zr.service.CkgrxxService;
import com.zr.serviceimp.CkgrxxServiceImpl;
/**
 * 
 * @author 李昱
 * 顾客查询个人信息的Controller
 * @param pid
 * @return
 */
public class CkgrxxController extends HttpServlet {

	CkgrxxService cks=new CkgrxxServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub

		req.setCharacterEncoding("utf-8");	
		resp.setCharacterEncoding("utf-8");
		PrintWriter  pw = resp.getWriter();
		HttpSession session =req.getSession();
		String uname=(String) session.getAttribute("uname");
		Customer c=cks.getCuByUname(uname);
		session.setAttribute("uid", 2);
		session.setAttribute("aaa", 21);
		JSONObject  j = new JSONObject();
		JSONArray j1=new JSONArray();
		j1.add(c);		
		j.put("total", 1);
		j.put("rows", j1);
		 pw.write(j.toString());
			pw.flush();
			pw.close();
	}
}
